package com.zixi.ai.framework.entity;

import com.zixi.ai.common.utils.uuid.SnowflakeUtil;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;

import java.io.Serializable;

/**
 * @author wfg
 */
public class SnowFlakeIdGenerator implements IdentifierGenerator {

    @Override
    public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
        // 调用雪花算法生成唯一ID
        return SnowflakeUtil.getSnowflake();
    }
}
